POV-Ray : Newsgroups : povray.binaries.images : Rounded Prisms : Re: Rounded Prisms Server Time
4 May 2024 03:45:09 EDT (-0400)
  Re: Rounded Prisms  
From: PM 2Ring
Date: 25 Nov 2005 04:50:01
Message: <web.4386daf17ed7ae6c2eef1b3b0@news.povray.org>
"Joanne Simpson" <cor### [at] onewhiteravencom> wrote:
> > Look fantastic - could make some great abstract images using these!! Be
> > great to post the source.  Great work!  Adrian

Thanks, Adrian.

>
> yes, please post the source - I am looking for some nice tesselations /
> Penrose tilings for a garden pavement.
> Joanne

Hi Joanne,

Here's a scene that uses two different Penrose tilings. I've posted an image
of this scene before, but I didn't post the source. I've been meaning to
tidy it up & add more comments, but... :) One day, I'd like to do more with
this scene, but I think I need to buy more memory first.

As for the scene, as well as using rounded regular polygonal prisms, it has
a nice macro for making rounded isoceles triangles. It also illustrates one
way of getting multicoloured objects using the object pattern. Oh, and it
also has a dodecahedron (or two) hiding inside. :)

// ----------------------------------------

// Persistence of Vision Ray Tracer Scene Description File
// File: Penrose.pov
// Vers: 3.6
// Desc: Penrose tiles. Penrose triangle macros modified from John
VanSickle's Boxer
// Date: 2005.02.26
// Auth: PM 2Ring
//
// -F -A0.5 +AM2 +R1
// +A0.3 +AM2 +R2 -D
// +A0.05 +AM2 +R3 -D
// +A0.025 +AM2 +R2

//Set to 1 when rendering 3D pairs with StereoPOV
#declare Use_Stereo=0;

#if(Use_Stereo)
  #version unofficial stereopov 0.2;
#else
  #version 3.6;
#end

//Some rendering and scene element boolean parameters
#declare Radio = 0;
#declare Photons = 0;
#declare Area_Lights = 0;

//Element selection
#declare Do_Sky = 1;          //Clouds?
#declare Do_Skysphere = 1;    //Skysphere or background

#declare Do_Room = 1;
#declare Do_Walls = 1;
#declare Do_Base = 1;
#declare Do_Floor = 1;
#declare Do_Seats = 1;
#declare Do_Dodec = 0;        //Glass dodecahedron
#declare Do_Water = 1;

//Scene control
#declare View_Overhead = 0;
#declare Do_Rounded = 1;      //Tile: rounded edges & points
#declare Do_Reflect = 1;      //Tile & wall reflection
#declare Disperse = 0;        //Glass dispersion sample number. 0 for no
dispersion

//Other parameters
#declare Rdepth = 4;          //Recursion depth for tiles   6

#declare SkyRad = 1E3;
#declare Rad = 60;

// ----------------------------------------

global_settings {
  assumed_gamma 1 // 1.5
  max_trace_level 20 //45

#if(Photons)
  photons {
    count 150000
    autostop 0
  }
#end

#if(Radio)
  radiosity {
    pretrace_end .08
    //count 60

    //nearest_count 6
    //error_bound 1.5     //default 1.8    0.4
    //recursion_limit 3

    gray_threshold .1 //.125
    low_error_factor 0.8
    brightness 1

    adc_bailout 0.01/2
    always_sample off
  }

  //ambient_light 0.2
#end
}

// ----------------------------------------

camera{
#if(View_Overhead)
  orthographic
#end

#if(1)
  location  vnormalize(<.65, 1.80, -5.0>) * Rad //* 1.125
  look_at   <-.5, 5.75, 0>
#else
  location  vnormalize(<0, 5, 0>) * Rad * .99 * 1.3 * 1.55
  //look_at   0
  look_at   0*6.5*y - 20.25*z
#end

  right     x*image_width/image_height up y
  angle 45

  #if(Use_Stereo)
   window_distance Rad * 1.75 * .8
    cross_eyed
 #end
}

light_source{
  vnormalize(<-1.5, 15, -20>) * .15 * SkyRad // SkyRad
  rgb 1.25

  #if(Area_Lights)
    #declare AL = 6;
    #declare ASize = 120;
    area_light x*ASize, z*ASize, AL, AL
    adaptive 1
    jitter
    circular
    orient
  #end

  photons {
    reflection on
    refraction on
    //#if(Area_Lights) area_light #end
  }
}

// ---Textures-------------------------------------
#declare SkyBlue = rgb<.035, .27, .67>+.125;    //For water & sky in 8-bit:
9 69 171

//Make a color_map from a0 to a1
#macro CMRange(a0, a1)color_map{[0 a0][1 a1]}#end

//Make a color_map from Black to a
#macro CMFull(a)CMRange(rgb 0, a)#end

#declare CM_Clouds2 =
color_map{
    [0.0   rgb 1 filter .05]
    [0.05  rgb 0.85 filter .15]
    [0.15  rgbf 0.75 filter .25]
    [0.525 rgbf 1]
    //[0.525 SkyBlue]
}

#declare CM_Stone =
color_map {
    [0.00 rgb 1]
    [0.10 rgb 0.75]
    //[0.30 SkyBlue ]
    [0.30 rgb<.5, .2, .2> ]
}

#declare T_Clouds =
texture{
  pigment{
    bozo
    color_map{CM_Clouds2}

    warp{
      turbulence .25
      octaves 6
      omega 0.7
      lambda 2.25
    }
  }
  //finish{ambient 1.325 diffuse 0.2}
  finish{ambient .9 diffuse 0.1}
}

#declare FTile = finish{
  phong .25 phong_size 160
  specular .5 roughness 1.5e-4

  #if(Do_Reflect)
    diffuse 0.70 ambient 0.05*0
    reflection {
      0.15  // .175
      //0.75 metallic
    }
    //conserve_energy
  #else
    diffuse 0.875 ambient 0.1
  #end

  //metallic
  //brilliance 2
}

#declare PWall=pigment{
    marble
    turbulence .65
    color_map{[0 rgb .45][0.1 rgb .75][1 rgb 1]}
    //rgb .9
    scale 1.875
}

#declare FWall=finish{
  specular .5 roughness 1e-3
  phong .25  phong_size 200
  ambient 0.1 diffuse .75
#if(Do_Reflect)
  ambient 0.03*0 diffuse .65
  reflection .15 //
#end
}

#declare TWall0=texture{
  pigment{PWall}
  finish{FWall}
  //normal{granite .1  scale 3e-4}
}

#declare TWall=texture{
  pigment{
    radial
    pigment_map{
      #declare I=0;
      #while(I<1)
        [I PWall rotate I*360*y translate I*z*Rad]
        [I+.1 PWall rotate I*360*y translate I*z*Rad]
        #declare I=I+.1;
      #end
    }
  }
  finish{FWall}
  //normal{granite .1  scale 3e-4}
}

#declare TGrout=texture{
  pigment{
    //granite scale 2e-5
    //color_map{[0.1 rgb .5][0.5 rgb 1]}
    //rgb .9
    rgb <.9 .95 1> * .9
  }
  finish{
    ambient 0.05
    //ambient 0.2
    diffuse .8
  }
  //normal{granite .1  scale 3e-4}
}

#declare TSeat =
texture{
  pigment{
    PWall rotate y*90
    //crackle
    //color_map {CM_Clouds2}
    //color_map {CM_Stone}
    color_map{[0 rgb .45][0.1 rgb .75][1 rgb 1]}
  }
  finish{
    ambient .05 diffuse .65
    specular .5 roughness 1e-3
    reflection .15
  }
}

#declare TWater=texture{
  pigment{
    //rgb <.8 .95 1> * .85
    //SkyBlue * .85
    rgb <.1 .6 .5>
  }
  finish{
    ambient 0.025 diffuse .15 reflection {.05, .9}
    conserve_energy
    metallic
  }
  normal{wrinkles .45 turbulence .055 scale 52 bump_size .105 }
}

#declare TGlass = texture
{
  finish
  {
    ambient 0
    diffuse 0.15 //.2
    reflection {0.05, 1 fresnel}

    specular .75
    roughness 0.0001
    //brilliance 1.5
    conserve_energy
  }
  pigment { color rgbf <0.985, .9975, .990, 1> }
}

#declare TTile=texture{
  pigment{
    marble turbulence .65
    color_map{[0 rgb .45][0.1 rgb .75][1 rgb 1]}

    rotate x*90 scale 3
  }
  finish{FTile}
  //normal{granite .15 scale 1e-4}
}

//Tile textures
#declare Pig3=rgb 1;             //white
//#declare Pig3=rgb <1 .65 .65>;             //red
#declare Pig2=rgb <1 .85 .45>;         //yellow
#declare Pig1=rgb <.45 .675 1>;        //blue

//Boost colour to compensate for averaging process, where it gets averaged
with Pig1
#macro Boost(A,B) 2*A-B #end
#declare Pig2=Boost(Pig2, Pig3);         //yellow
#declare Pig1=Boost(Pig1, Pig3);        //blue

//Tile textures
#declare Tex3=
//texture{TTile}
texture{
  pigment{Pig3}
  //finish{FTile}
}

#declare Tex2=
//texture{TTile}
texture{
  pigment{Pig2}
  //finish{FTile}
}

#declare Tex1=
//texture{TTile}
texture{
  pigment{Pig1}
  //finish{FTile}
}

// --------------------------------------------------------------

#declare Top = .30;     //Tile top height
#declare Mid = Top / 2; //Tile Middle height
#declare Sep = ((Do_Rounded)?Mid:0) + Mid * .07*2;      //Tile separation
...15

// ----------------------------------------

//Convert 2D vector to 3D, at height Mid
#macro XYZ(Q)<Q.u,Mid,Q.v>#end

//Convert 3D to 2D
#macro XZ(Q) <Q.x, Q.z> #end

//Make a simple triangle tile
#macro Tri0(A2,B2,C2) prism{linear_spline -1e-3,Top+1e-3,4, A2,B2,C2,A2}#end

//Make an isoceles triangle tile, with room for mortar
#macro Tri(A2,B2,C2)
    //Convert points to 3D
    #local A3 = XYZ(A2);
    #local B3 = XYZ(B2);
    #local C3 = XYZ(C2);

    //Find centre = intersections of angle bisectors
    #local M3 = (B3 + C3)/2;      //Midpoint of base
    #local A = vlength(C2-B2)/2;  //Half-Length of base
    #local S = vlength(A2-B2);    //Length of sloping side
    //#local SS = vlength(A2-C2);    //Length of other sloping side
    //#if(S!=SS)
    //  #debug concat("nApex Wrong! AB= ", str(S,0,0), " AC= ", str(SS,0,0),
" BC= ", str(2*A,0,0))
    //#end

    #local Cen = (A*A3 + S*M3)/(A + S);               //Interpolate from M
to A to find centre
    #local Sc = 1 - Sep * (A+S)/(A*sqrt(S*S-A*A));    //Scale factor to get
mortar+roundness width

#if(Do_Rounded)
  union{
    prism{
      linear_spline 0,Top,4
      A2,B2,C2,A2
    }
    union{
        cylinder{A3,B3,Mid}
        cylinder{B3,C3,Mid}
        cylinder{C3,A3,Mid}
        sphere{A3, Mid}
        sphere{B3, Mid}
        sphere{C3, Mid}
        //pigment{rgb 1}finish{phong .5 phong_size 200  reflection 0}
    }
#else
  prism{
    linear_spline 0,Top,4
    A2,B2,C2,A2
#end

    //Scale to create border Sep units wide
    translate -Cen
    scale <Sc, 1, Sc>
    translate Cen
  }
#end

#debug "nIgnore following warning, this union intentionally emptyn"
#declare Null = union{}
#debug "Ignore previous warning, this union intentionally emptyn"

#declare SetT = Null;
#declare SetP = array[2]{Null, Null};

#macro AddTri(A,B,C) #declare SetT = union{object{SetT} Tri(A,B,C)} #end
#macro AddTri0(A,B,C,P) #declare SetP[P] = union{object{SetP[P]}
Tri0(A,B,C)} #end

// ---Penrose triangle macros-------------------------------------

//Interpolate from A to B
#macro inter(A,B,r) (A+(B-A)*r) #end

#declare Phi=(sqrt(5)+1)/2;            //The Golden ratio
#declare phi=Phi-1;

#macro PutSlim(A,B,C,P)
  AddTri(A,B,C)

  #local E = inter(A,B,.5);
  #local F = inter(A,C,phi);
  #local G = inter(B,C,Phi/2);

  //AddTri0(C,F,G)       //colour 3

  AddTri0(A,E,F,P)
  AddTri0(B,E,F,!P)
  AddTri0(B,G,F,!P)
#end

#macro PutWide(A,B,C,P)
  AddTri(A,B,C)

  #local E = inter(B,A,Phi/2);
  #local F = inter(B,C,phi);

  //AddTri0(A,F,E)   //colour 3
  //AddTri0(A,F,C)   //colour 3

  AddTri0(B,E,F,!P)
#end

#macro Slim(A,B,C,D,P)
  #if(D=0)
    PutSlim(A,B,C,P)
  #else
    #local E = inter(A,B,phi);
    #local F = inter(C,A,phi);

    Wide(F,E,A,D-1,P)
    Slim(C,E,F,D-1,P)
    Slim(C,E,B,D-1,P)
  #end
#end

#macro Wide(A,B,C,D,P)
  #if(D=0)
    PutWide(A,B,C,P)
  #else
    #local E = inter(C,B,phi);

    Wide(E,A,B,D-1,1-P)
    Slim(C,A,E,D-1,1-P)
  #end
#end

// ----------------------------------------

#declare Ang = pi/5;
#declare Ang0 = radians(-117);
#declare Ang1 = radians(-81);

#if(Do_Room)
#if(Do_Floor)
//Fill Sets with triangles & pentagons
Slim(<0,0>, <cos(Ang0), sin(Ang0)>*Rad, <cos(Ang1), sin(Ang1)>*Rad, Rdepth,
0)

#declare PentaPig=
pigment{
  average
  pigment_map{
    [1 object{SetP[0] Pig3, Pig1}]
    [1 object{SetP[1] Pig3, Pig2}]
  }
}

#declare Wedge=
object{
  SetT
  pigment{PentaPig}
  finish{FTile}
}

#declare Floor =
union{
#declare I=0;
#while(I<5)
  object {Wedge rotate y*72*I}
  object {Wedge matrix <0,0,-1, 0,1,0, -1,0,0, 0,0,0> rotate y*72*I}
  #declare I=I+1;
#end
  rotate (0*90-9)*y

#if(1)
 photons {
   //target
   refraction off
   reflection on
   collect on
  }
#end
}
#end

//Decagon base for tiles
#if(Do_Base)
#declare Base =
prism{linear_spline -Top*2, Mid, 11,
#declare I=0;
#while(I<=10)
  <cos(Ang*I), sin(Ang*I)>* (Rad*1.1 + Sep)

  #declare I=I+1;
#end
  //no_shadow

  texture{TGrout}
}
#end

//Decagon room
#if(Do_Walls)
#declare Walls =
prism{linear_spline Mid, Rad/18, 22,
#declare I=0;
#while(I<=10)
  <cos(Ang*I), sin(Ang*I)>* (Rad + Sep)

  #declare I=I+1;
#end

#declare I=0;
#while(I<=10)
  <cos(Ang*I), sin(Ang*I)>* (Rad*1.1 + Sep)

  #declare I=I+1;
#end

  texture{TWall}
}
#end

#declare DR = (phi + 1)/sqrt(phi+3);
#declare DA = DR / (phi * phi * 2);
#declare DScale = Rad *pow(phi,4) / 1.258408572;
//#declare SR = .05;
#declare DHi = (Top + 1e-4) * y;

#if(Do_Dodec)
//Simplified from "shapes2.inc"
#declare Dodecahedron =
intersection
{
#declare Ax = degrees(atan2(1,2));
#declare I=0;
#while(I<5)
  plane {-z, 1 rotate <-Ax,    -72*I, 0>}
  plane {-z, 1 rotate < Ax, -36-72*I, 0>}
  #declare I=I+1;
#end

  plane { y, 1}
  plane {-y, 1}

  bounded_by {sphere {0, 1.2585}}
}

#declare Dodec =
object{
  Dodecahedron

  //pigment{rgb 1} finish{ambient 0 diffuse .1 specular .3 reflection .9}
  texture {TGlass}
  interior{
    //ior 1.75
    ior 1.1

    #if(!Photons) caustics 1 #end
    #if(1)
      #if(Disperse>0)
        dispersion 1.012
        dispersion_samples Disperse
      #end

      fade_distance Rad * 2//* phi
      fade_power 2 // 1001
      fade_color rgb <0, 0, .25>
    #end
  }

  rotate 18*y
  translate y
  scale DScale
  translate DHi

#if(1)
 photons {
   target
   refraction on
   reflection on
   collect off
  }
#end
}
#end

//Convert 2D to 3D, height H
#macro V3D(A, H)<A.u,H,A.v>#end

//Rounded Prism
#macro RPrism(Sides, Rad0, SH, SR)
  #local Ang = 2*pi/Sides;
  #local Rad = Rad0 - SR;
  #local Vtx = array[Sides+1];    //To store polygon vertices
  //#local Panel = box{<0,0,-SR>, <2*Rad*sin(Ang/2), SH-SR, SR>}   //Side
panel
  #local Panel = box{0, <2*Rad*sin(Ang/2), SH-SR, -SR>}   //Side panel - New
improved!

  union{
    prism{
      linear_spline 0, SH, Sides+1,
      #local I=0;
      #while(I<=Sides)
        #local Vtx[I] = <cos(Ang*I), sin(Ang*I)>*Rad;
        Vtx[I]
        #local I=I+1;
      #end
    }

    #local SH = SH - SR;
    #local I=0;
    #while(I<Sides)
      #local II = mod(I+1,Sides);
      #local A0 = V3D(Vtx[I],0);
      #local A1 = V3D(Vtx[I],SH);

      sphere{A1, SR}
      cylinder{0, SH*y, SR translate A0}
      cylinder{A1, V3D(Vtx[II],SH), SR}
      object{Panel rotate -y*(90 + 360*(I+.5)/Sides) translate A0}

      #local I=I+1;
    #end

    #if(mod(Sides,2)=1) rotate -y*90/Sides #end
  }
#end

#declare SRad = Rad*pow(phi,5);
#declare Seat =
object{
  RPrism(10, SRad, SRad*phi, SRad*.1)

  texture{TSeat}
  //pigment{rgb 1}
  //finish{specular .5 roughness 1e-3 reflection .25 diffuse .8}

  translate Top*y
}

// ---Scene-------------------------------------

//Room & contents
union{
  #if(Do_Base) object{Base} #end
  #if(Do_Floor) object{Floor} #end
  #if(Do_Walls)
    //Footing
    object{Walls}
    #declare I=0;
    #while(I<10)
      //Columns
      cylinder{0, 8*y, .015*Rad translate <0, Rad/18.01, Rad> rotate
360*y*I/10 texture{TWall0}}
      cylinder{0, 8*y, .015*Rad translate <0, Rad/18.01,
Rad*1.1*sqrt(4*phi+7)*phi/2> rotate 360*y*(I+.5)/10 texture{TWall0}}
      #declare I=I+1;
    #end
    //Handrail
    object{Walls scale<1, 2*phi-1, 1> texture{TWall} translate
y*(8+Rad/18.02)}
  #end

  #if(Do_Dodec)
    object{Dodec rotate 0*180*y}
  #end

  #if(Do_Seats)
    #declare SRad = DR*DScale/DA;
    #if(0)
    object{
      RPrism(10, SRad, SRad*phi, SRad*.2)
      texture{TSeat}
      //texture{TTile}

      translate Top*y
    }
    #end

    #declare I=1;
    #while(I<5)
      object{Seat //pigment{rgb I/5}
        translate Rad*x*phi
        rotate y*72 * (I+1)
      }
      #declare I=I+1;
    #end
  #end

  rotate 18*y

#if(View_Overhead)
  scale .375 rotate -90*x
#end
}
#end

// ---Sky & Water-------------------------------------

//Water
#if(Do_Water)
object{
  sphere{-y*SkyRad*9.75, SkyRad*9.75}

  translate -y*5 //5
  texture{TWater scale .2}
}
#end

#declare Sky =
sphere{-y*SkyRad*9.750, SkyRad*10
  inverse
  no_shadow

  texture{
    T_Clouds
    rotate <18, 65, 0>
    scale  <1 .7 1> * SkyRad  * .325
  }
}

#if(Do_Sky)object{Sky}#end

#if(Do_Skysphere)
  sky_sphere{
    pigment{
      function{y}
      color_map{
        [0.0 SkyBlue]
        [0.19 rgb <0.0,0.1,0.8>*.675]
      }
      translate -y * .08
      scale 1.7
    }
  }
#else
  background{
    SkyBlue
    //rgb 0.25
  }
#end

// ----------------------------------------


Warning: the newsgroups's Web interface eats up backslashes, so you may want
to restore them in the #debug commands.


Post a reply to this message


Attachments:
Download 'rprismdi2s.jpg' (110 KB)

Preview of image 'rprismdi2s.jpg'
rprismdi2s.jpg


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.